package ui.activity.mine.biz;

import base.BaseBiz;
import base.BaseResp;
import coom.BaseSubscribe;
import coom.RetrofitHelp;
import okhttp3.RequestBody;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by chenjian on 19/2/26.
 * 1
 */

public class NewAddressBiz extends BaseBiz {

    /**
     * 新增地址
     */
    public void addAddress(RequestBody requestBody, final Callback<Object> callback) {
        com.add(RetrofitHelp.getSecretApi().addAddress(requestBody)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<Object>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((Object) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((Object) obj);
                    }
                })
        );
    }

    /**
     * 编辑地址
     */
    public void editAddress(RequestBody requestBody, final Callback<Object> callback) {
        com.add(RetrofitHelp.getSecretApi().updateAddress(requestBody)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<Object>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((Object) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((Object) obj);
                    }
                })
        );
    }


}
